import React from 'react'
import axios from 'axios'
const Index = () => {
	const order_id = +new Date()
	const total_price = 81
	const project = '华为mate 50'
	const detail = '这是商品详情'

	const handlePayment = async () => {
		const resp = await axios.post('/api/payment', {
			order_id, total_price, project, detail
		})
		window.location.href = resp.data.data.url
	}
	
	return (
		<div>
			<h2>订单号: {order_id}</h2>
			<h2>金额: {total_price}</h2>
			<h2>标题: {project}</h2>
			<button onClick={() => handlePayment()}>去下单</button>
		</div>
	)
}

export default Index;